const res = sum(10, 20)
console.log(res)

var sum = function(a, b) {
  return a + b
}

/*

const res = sum(10, 20)
console.log(res)

const sum = function(a, b) {
  return a + b
}

--------------------------

const res = sum(10, 20)
            ^

ReferenceError: Cannot access 'sum' before initialization
    at Object.<anonymous> (/Users/mac/JALProjects/WebTest/http-server/fn.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1144:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
    at Module.load (internal/modules/cjs/loader.js:993:32)
    at Function.Module._load (internal/modules/cjs/loader.js:892:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

*/


/*
const res = sum(10, 20)
console.log(res)

var sum = function(a, b) {
  return a + b
}

/Users/mac/JALProjects/WebTest/http-server/fn.js:1
const res = sum(10, 20)
            ^

TypeError: sum is not a function
    at Object.<anonymous> (/Users/mac/JALProjects/WebTest/http-server/fn.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1144:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
    at Module.load (internal/modules/cjs/loader.js:993:32)
    at Function.Module._load (internal/modules/cjs/loader.js:892:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

*/